﻿<%


Public Function GetGameCategories(ByRef objCn)

    Dim cats(), i
    ReDim cats(8 - 1) '八个大类
   
    '热门游戏
    cats(0) = GetGamesBySQL("select * from game where ishot=1 and isShow=1 order by index_string", objCn)
    
    i = 1
    For Each cat in Array("'A','B','C','D'", "'E','F','G','H'", "'I','J','K','L'", "'M','N','O','P'", "'Q','R','S','T'", "'W','X','Y','Z'")
        cats(i) = GetGamesBySQL("select * from game where index_string in ("&cat&") and isShow=1 order by LENGTH(game_name)", objCn)
        i = i + 1
    Next

    '其他游戏
    cats(i) = GetGamesBySQL("select * from game where isShow=0 order by index_string", objCn)

    GetGameCategories = cats
End Function

Private Function GetGamesBySQL(ByRef szSQL, ByRef objCn)

    Dim games(), game()
    Dim i

    Set rs = Server.CreateObject("ADODB.RecordSet")
    rs.CursorLocation = 3
    rs.Open szSQL, objCn , 1, 1

    ReDim games(rs.RecordCount - 1)
    i = 0

    Do While Not rs.EOF
        ReDim game(3 - 1) '三个属性

        game(0) = rs("game_id")
        game(1) = rs("game_name")
        game(2) = IIf(rs("ishot"), "game-hot", "")


        games(i) = game

        rs.MoveNext
        i = i + 1
    Loop

    rs.Close
    Set rs = Nothing 

    GetGamesBySQL = games

End Function




Public Function GetGameCategoriesFlat(ByRef objCn)

    Dim cats(), i
    ReDim cats(8 - 1) '八个大类
   
    '热门游戏
    cats(0) = GetGamesBySQLFlat("select card_name,card_info_id,photo from card_infor where card_info_id in (select card_infor_id from card_game where game_id in (select game_id from game where ishot=1 and isGame=1)) and onsale=1 order by best desc,hot desc limit 10", objCn)
    
    i = 1
    For Each cat in Array("'A','B','C','D'", "'E','F','G','H'", "'I','J','K','L'", "'M','N','O','P'", "'Q','R','S','T'", "'W','X','Y','Z'")
        cats(i) = GetGamesBySQLFlat("select card_name,card_info_id,photo from card_infor where card_info_id in (select card_infor_id from card_game where game_id in (select game_id from game where index_string in ("&cat&") and isGame=1)) and onsale=1 order by best desc,hot desc limit 10", objCn)
        i = i + 1
    Next

    '其他游戏
    cats(i) = GetGamesBySQLFlat("select card_name,card_info_id,photo from card_infor where card_info_id in (select card_infor_id from card_game where game_id in (select game_id from game where isGame=0)) and onsale=1 order by best desc,hot desc limit 10", objCn)

    GetGameCategoriesFlat = cats
End Function

Private Function GetGamesBySQLFlat(ByRef szSQL, ByRef objCn)

    Dim games(), game()
    Dim i

    Set rs = Server.CreateObject("ADODB.RecordSet")
    rs.CursorLocation = 3
    rs.Open szSQL, objCn , 1, 1

    ReDim games(rs.RecordCount - 1)
    i = 0

    Do While Not rs.EOF
        ReDim game(3 - 1) '三个属性

        game(0) = rs("game_id")
        game(1) = rs("game_name")
        game(2) = IIf(rs("ishot"), "game-hot", "")


        games(i) = game

        rs.MoveNext
        i = i + 1
    Loop

    rs.Close
    Set rs = Nothing 

    GetGamesBySQLFlat = games

End Function



%>
<script language="javascript" type="text/javascript">
    $(document).ready(function () {

        var tabs = $("#menu2 li a");
        var cats = $("div.category-content ul");

        tabs.bind("click", function () {

            $("#menu2 li.greeting").removeClass("greeting");
            $(this).parent().addClass("greeting");

            cats.hide(500);
            cats.eq($(this).attr("tabindex")).show(500);
        });

        tabs.first().click();
    })
</script>
<div class="activity-new-year">
    <a title="积分换礼" href="#"></a>
</div>
<div class="blank">
</div>
<div>
    <ul id="menu2">
        <li><a href="javascript:void(0)" tabindex="0">热门游戏</a></li>
        <li><a href="javascript:void(0)" tabindex="1">ABCD</a></li>
        <li><a href="javascript:void(0)" tabindex="2">EFGH</a></li>
        <li><a href="javascript:void(0)" tabindex="3">IJKL</a></li>
        <li><a href="javascript:void(0)" tabindex="4">MNOP</a></li>
        <li><a href="javascript:void(0)" tabindex="5">QRST</a></li>
        <li><a href="javascript:void(0)" tabindex="6">WXYZ</a></li>
        <li><a href="javascript:void(0)" tabindex="7">其他游戏</a></li>
    </ul>
</div>
<div class="category-content">
    <%For Each cat in GetGameCategories(conn) %>
    <ul>
        <%For Each game in cat %>
        <li><a href="<%=MapUrl2("cardbygame", "game_id", game(0)) %>" title="<%=game(1) %>"
            class="<%=game(2) %>">
            <%=game(1) %></a></li>
        <%Next%>
    </ul>
    <%Next%>
    <div class="blank">
    </div>
</div>
<div class="blank">
</div>
